package com.example.tossednfound;

/**
 * Parent class for AdminUser and RegUser
 */

public abstract class User {
	String email;
	String password;
	String address;
	String state;
	int zipcode;
	String country;
	String name;	
	int loginCount;
	public boolean isLocked;
	/**
	 * checks the inputed username and password to see if it matches the User's
	 * 
	 * @param emailin
	 * @param passwordin
	 * @return
	 */
	public boolean checkCredentials(String emailin, String passwordin){
		if(emailin.equals(email)){
			if (loginCount > 2) {
				isLocked = true;
				return false;
			}
			loginCount++;
			if(passwordin.equals(password)) loginCount = 0;
			return passwordin.equals(password);
		}
		return false;
	}
	
	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return (email != null ? " Email: " + email + ", " : "")
				+ (password != null ? " Password: " + password : "" + ", Is Locked: " + isLocked);
	}

}